package com.example.exporttemplate.controller.FreeMarkerExport;

import com.example.exporttemplate.service.FreeMarkerExportService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * freemarker模板引擎导出word
 *
 * @author liulindong
 * @version 2022/9/21 23:00
 */
@RestController
@RequestMapping("/freemarker")
public class FreeMarkerExportWordController {

    private final FreeMarkerExportService freeMarkerExportService;

    public FreeMarkerExportWordController(FreeMarkerExportService freeMarkerExportService) {
        this.freeMarkerExportService = freeMarkerExportService;
    }


    /**
     * 通过xml方式导出word
     * @param response http响应
     */
    @GetMapping("/export/by_docx")
    public void export(HttpServletResponse response) {
        freeMarkerExportService.exportFreeMarkerByDocx(response);
    }

    /**
     * 通过html方式导出word
     * @param response http响应
     */
    @GetMapping("/export/by_html")
    public void exportByHtml(HttpServletResponse response) {
        freeMarkerExportService.exportFreeMarkerByHtml(response);
    }
}
